Skip to content

[NDGL-108] Build Variant 설정, API Key Interceptor 추가, 난독화 설정#31

Merged
jihee-dev merged 5 commits into
developfrom
feature/NDGL-108/add-build-variant-and-network-header
Feb 20, 2026
Merged

[NDGL-108] Build Variant 설정, API Key Interceptor 추가, 난독화 설정#31
jihee-dev merged 5 commits into
developfrom
feature/NDGL-108/add-build-variant-and-network-header

Conversation

@jihee-dev
Copy link
Copy Markdown
Member

@jihee-dev jihee-dev commented Feb 20, 2026

NDGL-108 Build Variant 및 네트워크 요청 검증 헤더 추가, 난독화 설정


연관 문서

변경사항

  • 서버 Base URL을 Build Type별로 분리

    • app/build.gradle.kts에 debug / release buildType 명시적 설정 추가
    • local.properties에서 NDGL_BASE_URL_DEBUG, NDGL_BASE_URL_RELEASE를 읽어 각 빌드타입에
      BuildConfig.NDGL_BASE_URL로 주입
    • data/core의 NetworkModule에서 provideBaseUrl() 제거 → app 모듈의 AppNetworkModule로 이전
      (BuildConfig 기반)
    • @baseurl qualifier annotation 추가하여 DI 모호성 제거
    • Release 서명 설정(signingConfig) 추가
    • applicationIdSuffix = ".debug" 적용 (debug 빌드 구분)
  • API Key Interceptor 추가

    • ApiKeyInterceptor 신규 생성 — 모든 요청에 X-API-KEY 헤더 자동 추가
    • @apikey qualifier annotation 추가
    • AppNetworkModule에서 BuildConfig.NDGL_API_KEY를 @apikey로 제공
    • provideDefaultOkHttpClient, provideAuthOkHttpClient 모두에 ApiKeyInterceptor 적용
    • local.properties에 NDGL_API_KEY 키 추가 필요
  • Proguard 설정 방식 변경 (refactor)

    • 기존: KotlinAndroid.kt의 configureKotlinAndroid()에서 각 라이브러리 모듈에 proguard-rules.pro 일괄
      적용
    • 변경: 각 모듈의 consumer-rules.pro로 분리하여 라이브러리 소비 시점에 규칙 적용
    • NDGLAndroidLibraryPlugin, NDGLDataPlugin에 consumerProguardFiles("consumer-rules.pro") 추가
    • 각 모듈의 proguard-rules.pro 제거 → consumer-rules.pro로 대체
    • app/build.gradle.kts에서 all { proguardFiles(...) } 블록으로 앱 수준 Proguard 통합 관리

테스트 체크 리스트

  • debug 빌드 테스트
  • release 빌드 테스트

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 릴리스 빌드 서명 구성 추가
    • API 키 자동 주입 메커니즘 추가
  • 개선 사항

    • 릴리스 빌드 코드 난독화 및 최적화 강화
    • 디버그 빌드 표식 개선
    • 모듈 간 의존성 구조 최적화
  • 기타

    • ProGuard 규칙 통합 및 정리

@jihee-dev jihee-dev self-assigned this Feb 20, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 20, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

워크스루

앱 수준의 빌드 구성 파일에서 기본 URL과 API 키를 BuildConfig 필드로 이동하고, 릴리스 빌드를 위한 서명 설정을 추가했습니다. API 키 인터셉터를 통해 모든 요청에 API 키를 자동으로 주입하는 DI 모듈을 도입했으며, 모듈 수준의 ProGuard 규칙을 consumer 규칙으로 통합하고 중복 구성을 제거했습니다.

변경사항

변경 그룹 / 파일 요약
앱 빌드 구성
app/build.gradle.kts, app/proguard-rules.pro
로컬 속성에서 서명 설정 및 buildConfigFields(NDGL_API_KEY, NDGL_BASE_URL)를 추가하고, 디버그/릴리스 빌드 타입을 구성했습니다. ProGuard 규칙에서 Google j2objc 어노테이션에 대한 경고 제외를 추가했습니다.
DI 및 네트워크 모듈
app/src/main/java/com/yapp/ndgl/di/AppNetworkModule.kt, data/core/src/main/java/com/yapp/ndgl/data/core/di/NetworkModule.kt, data/core/src/main/java/com/yapp/ndgl/data/core/interceptor/ApiKeyInterceptor.kt, data/auth/src/main/java/com/yapp/ndgl/data/auth/di/AuthNetworkModule.kt
AppNetworkModule을 신규 추가하여 BuildConfig의 기본 URL과 API 키를 싱글톤으로 제공하도록 설정했습니다. ApiKeyInterceptor를 신규 추가하여 모든 요청에 X-API-KEY 헤더를 자동으로 주입했습니다. NetworkModule에서 provideBaseUrl() 함수를 제거하고 @BaseUrl 한정자를 통해 기본 URL을 주입하도록 변경했으며, ApiKeyInterceptor를 OkHttpClient에 추가했습니다. AuthNetworkModule의 baseUrl 파라미터에 @BaseUrl 한정자를 추가했습니다.
빌드 로직 플러그인
build-logic/src/main/kotlin/NDGLAndroidLibraryPlugin.kt, build-logic/src/main/kotlin/NDGLDataPlugin.kt, build-logic/src/main/kotlin/convention/KotlinAndroid.kt
NDGLAndroidLibraryPlugin과 NDGLDataPlugin에서 consumer-rules.pro 파일을 기본 설정으로 추가했습니다. KotlinAndroid에서 릴리스 빌드 타입 설정을 제거했습니다.
모듈별 ProGuard 규칙 통합
data/auth/proguard-rules.pro, data/auth/consumer-rules.pro, data/core/proguard-rules.pro, data/core/consumer-rules.pro, data/travel/proguard-rules.pro, data/travel/consumer-rules.pro, feature/.../*.pro, navigation/.../*.pro
모듈 수준의 ProGuard 규칙 파일(proguard-rules.pro)을 제거하고, consumer-rules.pro에 패키지별 keep 규칙(model, api, serializer 패키지)을 추가했습니다. 특히 core/ui/proguard-rules.pro 및 모든 feature 모듈의 규칙 파일은 전체 내용을 제거했습니다.
기타 구성
data/core/build.gradle.kts, app/src/debug/res/values/strings.xml
data/core/build.gradle.kts에서 로컬 속성 로더와 buildConfigField를 제거했습니다. app/src/debug/res/values/strings.xml에 디버그 앱 이름 문자열을 추가했습니다.

예상 코드 검토 노력

🎯 3 (Moderate) | ⏱️ ~20 분

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 PR의 주요 변경 사항들을 정확하게 반영합니다: 빌드 Variant 설정, API Key Interceptor 추가, 난독화 설정 모두 변경 사항에 포함되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/NDGL-108/add-build-variant-and-network-header

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (5)
data/travel/consumer-rules.pro (1)

2-2: -keep interface-keep class 변경 권장

-keep interfaceinterface 선언 타입만 보호하며, 같은 패키지 내 class, enum, @interface(어노테이션 타입)는 난독화/제거 대상이 됩니다. 현재 api 패키지는 Retrofit 서비스 인터페이스(PlaceApi, TravelProgramApi, TravelTemplateApi, UserTravelApi)만 포함하고 있어 안전하지만, 향후 헬퍼 클래스나 어노테이션 타입이 추가될 경우 런타임 오류가 발생할 수 있습니다. 1번 줄과 일관성을 맞추기 위해서도 -keep class 사용을 권장합니다.

♻️ 제안 수정
-keep class com.yapp.ndgl.data.travel.model.** { *; }
--keep interface com.yapp.ndgl.data.travel.api.** { *; }
+-keep class com.yapp.ndgl.data.travel.api.** { *; }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@data/travel/consumer-rules.pro` at line 2, 현재 ProGuard/R8 규칙에서 사용된 "-keep
interface com.yapp.ndgl.data.travel.api.** { *; }"는 인터페이스만 보호하므로 향후 같은 패키지에 추가될
수 있는 클래스·enum·어노테이션을 보호하지 못합니다; 규칙을 "-keep class" 형태로 바꿔서
com.yapp.ndgl.data.travel.api 패키지 전체(예: PlaceApi, TravelProgramApi,
TravelTemplateApi, UserTravelApi와 향후 추가될 헬퍼/어노테이션 타입)를 난독화/제거 대상에서 제외하도록 수정하세요.
app/proguard-rules.pro (1)

21-21: [선택 사항] 릴리즈 빌드의 크래시 리포트 가독성을 위해 두 속성을 함께 활성화하는 것을 고려하세요.

현재 -renamesourcefileattribute SourceFile(Line 21)와 -keepattributes SourceFile,LineNumberTable(Line 17) 모두 주석 처리된 상태로 일관성은 있습니다. 다만, Firebase Crashlytics 등의 크래시 리포팅 툴과 함께 사용하는 경우, 두 옵션을 함께 활성화하면 ProGuard mapping 파일을 통해 릴리즈 빌드 스택 트레이스를 역난독화할 수 있어 디버깅이 용이해집니다.

-#-keepattributes SourceFile,LineNumberTable
+  -keepattributes SourceFile,LineNumberTable

-#-renamesourcefileattribute SourceFile
+  -renamesourcefileattribute SourceFile
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/proguard-rules.pro` at line 21, Uncomment and enable both ProGuard
directives to improve crash-report readability: remove the comment for
"-renamesourcefileattribute SourceFile" and also ensure "-keepattributes
SourceFile,LineNumberTable" is enabled so release-stack traces can be
deobfuscated via the mapping file; reference the exact directives
"-renamesourcefileattribute SourceFile" and "-keepattributes
SourceFile,LineNumberTable" when making the change.
navigation/consumer-rules.pro (1)

1-1: 네비게이션 모듈의 keep 규칙이 지나치게 넓습니다.

com.yapp.ndgl.navigation.**의 모든 클래스와 멤버를 유지하면 R8 최적화 효과가 감소합니다. 실제로 리플렉션이나 직렬화에 사용되는 클래스(예: route 정의, sealed class)만 keep하는 것이 좋습니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@navigation/consumer-rules.pro` at line 1, The current ProGuard/R8 keep rule
keeps the entire package com.yapp.ndgl.navigation.**, which is too broad; narrow
it to only the types actually needed at runtime via reflection/serialization
(e.g., route definitions and sealed classes). Replace the wildcard keep with
targeted keeps for specific classes or subpackages (for example, keep the route
definition classes and any sealed/ADT classes used by navigation) and avoid
keeping all members of the whole package so R8 can optimize the rest; locate the
rule referencing com.yapp.ndgl.navigation.** and change it to explicit keep
rules for the concrete class names or subpackages that require preservation.
app/build.gradle.kts (1)

34-40: all 블록의 proguardFiles 설정이 configureKotlinAndroid()와 중복될 수 있습니다.

기존 학습 내용에 따르면, configureKotlinAndroid()가 이미 release buildType에 ProGuard 파일을 구성합니다. all 블록에서 다시 proguardFiles()를 호출하면 모든 buildType(debug 포함)에 ProGuard 규칙이 중복 추가될 수 있습니다. debug에서는 isMinifyEnabled = false이므로 실질적 영향은 없지만, 중복 설정 여부를 확인해 주세요.

Based on learnings: "configureKotlinAndroid() already configures ProGuard files for the release buildType."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/build.gradle.kts` around lines 34 - 40, The proguardFiles call inside the
all { ... } block duplicates configuration already applied by
configureKotlinAndroid() and can add ProGuard rules to buildTypes unnecessarily;
remove the proguardFiles(...) invocation from the all block (or move it into an
explicit release buildType block) and keep only the buildConfigField("String",
"NDGL_API_KEY", ...) there so configureKotlinAndroid() remains the sole place
that configures ProGuard for release builds and you avoid duplicate
proguardFiles declarations.
data/core/src/main/java/com/yapp/ndgl/data/core/di/NetworkModule.kt (1)

104-114: [선택적 리팩토링] Qualifier 어노테이션을 별도 파일로 분리하는 것을 고려하세요.

AuthClient, BaseUrl, ApiKey 세 개의 qualifier가 모두 NetworkModule.kt에 정의되어 있습니다. 현재는 기존 AuthClient 패턴과 일관성이 있으나, qualifier가 늘어날수록 NetworkModule의 책임이 과중해집니다. 별도 파일(예: di/NetworkQualifiers.kt 또는 annotations/ 패키지)로 분리하면 단일 책임 원칙에 부합하고 임포트 경로도 더 명시적이 됩니다.

♻️ 예시: 별도 파일로 분리

data/core/src/main/java/com/yapp/ndgl/data/core/di/NetworkQualifiers.kt 신규 생성:

+package com.yapp.ndgl.data.core.di
+
+import javax.inject.Qualifier
+
+@Qualifier
+@Retention(AnnotationRetention.BINARY)
+annotation class AuthClient
+
+@Qualifier
+@Retention(AnnotationRetention.BINARY)
+annotation class BaseUrl
+
+@Qualifier
+@Retention(AnnotationRetention.BINARY)
+annotation class ApiKey

NetworkModule.kt에서 제거:

-@Qualifier
-@Retention(AnnotationRetention.BINARY)
-annotation class AuthClient
-
-@Qualifier
-@Retention(AnnotationRetention.BINARY)
-annotation class BaseUrl
-
-@Qualifier
-@Retention(AnnotationRetention.BINARY)
-annotation class ApiKey
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@data/core/src/main/java/com/yapp/ndgl/data/core/di/NetworkModule.kt` around
lines 104 - 114, The three qualifier annotations AuthClient, BaseUrl, and ApiKey
are declared inside NetworkModule and should be extracted into a dedicated file
to reduce NetworkModule responsibility; create a new Kotlin file (e.g.,
NetworkQualifiers.kt or an annotations package) containing the three
`@Qualifier/`@Retention declarations (retain the same annotation names and
AnnotationRetention.BINARY), remove them from NetworkModule, and update
imports/usages in NetworkModule and any other files to reference the moved
annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/build.gradle.kts`:
- Line 46: The build injects NDGL_BASE_URL_DEBUG/NDGL_BASE_URL_RELEASE via
buildConfigField using localProperties.getProperty(...) which returns null when
the key is missing and results in the literal "null" string in BuildConfig;
update the build logic around buildConfigField("String", "NDGL_BASE_URL", ...)
to supply a safe default (e.g., empty string or a validated fallback URL) when
localProperties.getProperty(...) is null — do this for both the DEBUG and
RELEASE variants by using a null-coalescing or getProperty(key, default)
approach (or an explicit null check) so BuildConfig.NDGL_BASE_URL never becomes
the string "null".
- Around line 20-27: The signingConfigs block crashes when
localProperties.getProperty("KEYSTORE_PATH") returns null; update the
create("release") block to guard all localProperties.getProperty(...) calls and
avoid calling file(null): fetch each property into local variables (e.g.,
keystorePath, keystoreStorePassword, keystoreAlias, keystoreKeyPassword), check
keystorePath for null/blank and only call file(keystorePath) and assign
storeFile when non-null, otherwise skip setting storeFile (and optionally skip
the whole signing config or set safe defaults); ensure storePassword, keyAlias
and keyPassword are set conditionally (or use safe fallback values) so
signingConfigs.create("release") no longer calls file(null) and does not crash
in CI.

---

Nitpick comments:
In `@app/build.gradle.kts`:
- Around line 34-40: The proguardFiles call inside the all { ... } block
duplicates configuration already applied by configureKotlinAndroid() and can add
ProGuard rules to buildTypes unnecessarily; remove the proguardFiles(...)
invocation from the all block (or move it into an explicit release buildType
block) and keep only the buildConfigField("String", "NDGL_API_KEY", ...) there
so configureKotlinAndroid() remains the sole place that configures ProGuard for
release builds and you avoid duplicate proguardFiles declarations.

In `@app/proguard-rules.pro`:
- Line 21: Uncomment and enable both ProGuard directives to improve crash-report
readability: remove the comment for "-renamesourcefileattribute SourceFile" and
also ensure "-keepattributes SourceFile,LineNumberTable" is enabled so
release-stack traces can be deobfuscated via the mapping file; reference the
exact directives "-renamesourcefileattribute SourceFile" and "-keepattributes
SourceFile,LineNumberTable" when making the change.

In `@data/core/src/main/java/com/yapp/ndgl/data/core/di/NetworkModule.kt`:
- Around line 104-114: The three qualifier annotations AuthClient, BaseUrl, and
ApiKey are declared inside NetworkModule and should be extracted into a
dedicated file to reduce NetworkModule responsibility; create a new Kotlin file
(e.g., NetworkQualifiers.kt or an annotations package) containing the three
`@Qualifier/`@Retention declarations (retain the same annotation names and
AnnotationRetention.BINARY), remove them from NetworkModule, and update
imports/usages in NetworkModule and any other files to reference the moved
annotations.

In `@data/travel/consumer-rules.pro`:
- Line 2: 현재 ProGuard/R8 규칙에서 사용된 "-keep interface
com.yapp.ndgl.data.travel.api.** { *; }"는 인터페이스만 보호하므로 향후 같은 패키지에 추가될 수 있는
클래스·enum·어노테이션을 보호하지 못합니다; 규칙을 "-keep class" 형태로 바꿔서
com.yapp.ndgl.data.travel.api 패키지 전체(예: PlaceApi, TravelProgramApi,
TravelTemplateApi, UserTravelApi와 향후 추가될 헬퍼/어노테이션 타입)를 난독화/제거 대상에서 제외하도록 수정하세요.

In `@navigation/consumer-rules.pro`:
- Line 1: The current ProGuard/R8 keep rule keeps the entire package
com.yapp.ndgl.navigation.**, which is too broad; narrow it to only the types
actually needed at runtime via reflection/serialization (e.g., route definitions
and sealed classes). Replace the wildcard keep with targeted keeps for specific
classes or subpackages (for example, keep the route definition classes and any
sealed/ADT classes used by navigation) and avoid keeping all members of the
whole package so R8 can optimize the rest; locate the rule referencing
com.yapp.ndgl.navigation.** and change it to explicit keep rules for the
concrete class names or subpackages that require preservation.

Comment thread app/build.gradle.kts
Comment thread app/build.gradle.kts
@jihee-dev jihee-dev force-pushed the feature/NDGL-108/add-build-variant-and-network-header branch 2 times, most recently from c25c2c2 to 10e57a6 Compare February 20, 2026 20:34
@jihee-dev jihee-dev force-pushed the feature/NDGL-108/add-build-variant-and-network-header branch from 10e57a6 to 7306636 Compare February 20, 2026 20:37
@jihee-dev jihee-dev merged commit 8f9a120 into develop Feb 20, 2026
4 checks passed
@jihee-dev jihee-dev deleted the feature/NDGL-108/add-build-variant-and-network-header branch February 20, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant